#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
    int strStr(string haystack, string needle)
    {
        // 让 needle 与 haystack 所有长度为 needle.size() 的字串匹配一次
        int n = haystack.size(), m = needle.size();
        // 匹配子串
        for (int i = 0; i + m <= n; i++) {
            bool flag = true;
            // 比较子串和 needle 的每个字符是否匹配,不匹配则退出
            for (int j = 0; j < m; j++) {
                if (haystack[i + j] != needle[j]) {
                    flag = false;
                    break;
                }
            }
            if (flag == true) {
                return i;
            }
        }
        return -1;
    }
};

int main()
{
    cout << "Hello World!" << endl;
    return 0;
}
